// Import Vue
import Vue from 'vue'

// Import F7
import Framework7 from 'framework7'

// Import F7 Vue Plugin
import Framework7Vue from 'framework7-vue'

// Import F7 iOS Theme Styles
import Framework7Theme from 'framework7/dist/css/framework7.ios.min.css'
import Framework7ThemeColors from 'framework7/dist/css/framework7.ios.colors.min.css'
/* OR for Material Theme:
import Framework7Theme from 'framework7/dist/css/framework7.material.min.css'
import Framework7ThemeColors from 'framework7/dist/css/framework7.material.colors.min.css'
*/

// Import App Custom Styles
import AppStyles from './css/app.css'
import Icons from '../static/icon/css/framework7-icons.css'
// Import Routes
import Routes from './routes.js'

// Import App Component
import App from './app'

// import 配置
import config from './config/index'
import product from './config/product'
import debug from './config/debug'
import helper from './common/helper'

// 运行模式
window.APP_MODE = false  //  true 为APP方式运行，false 为PC\WAP浏览器中
window.APP_STATUS = '' // product状态, debug状态
window.APP_DEBUG = (window.APP_STATUS === 'debug') //是否为debug模式

// 产品模式配置文件覆盖
if(window.APP_STATUS == 'product') {
    Object.assign(config, product)
} else if(window.APP_DEBUG) {
    Object.assign(config, debug)
}

// 自动检测是否为APP运行方式
window.document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    window.APP_MODE = true
    console.log(device.platform)
}

// 无需登录的测试数据
if(!helper.localStorage('token')) {
    helper.localStorage('token', config.site.token); // 设备上先写死token
}
if(!helper.localStorage('goverment')) {
    helper.localStorage('farmer', config.site.government); // 设备上先写死farmer
}


// Init F7 Vue Plugin
Vue.use(Framework7Vue)

// Init App
new Vue({
  el: '#app',
  template: '<app/>',
  // Init Framework7 by passing parameters here
  framework7: {
    root: '#app',
      modalButtonOk:'确认',
      modalButtonCancel:'取消',
    /* Uncomment to enable Material theme: */
    // material: true,
    routes: Routes,
  },
  // Register App Component
  components: {
    app: App
  }
});
